import java.io.File;
import java.io.IOException;
import java.util.Scanner;


public class TestCase extends junit.framework.TestCase {
	
	public void testeWrite() throws Exception {
		P2PPartFile p = new P2PPartFile("124124", 101, "nome.txt");
		byte[] data = "afjaiojajdf".getBytes();
		p.writeChunk(2, data);
	}
	
    public void testP2PSize() throws IOException, Exception {
    	File f = new File("share/button.png");
    	P2PCompFile p = new P2PCompFile(f.getName());
    	System.out.println("Nome: " + p.filename + "" +
    			" Tamanho: " + p.size + 
    			" Chunks: " + p.availableChunks.size() +
    			" Hash: " + p.sha_sb);
    	
    	//System.out.write(SHAChecksum.getMdSHAChecksumString(p.sha_sb));
    	System.out.println("HEY");
    	//System.out.write(SHAChecksum.getMdSHAChecksum("share/button.png"));
    }
    
    public void testP2PFileManager() throws Exception {
    	P2PFileManager a = new P2PFileManager();
    	for (P2PFile p : a.files) {
    		System.out.println(p.filename);
    		P2PCompFile b = (P2PCompFile) p;
    		System.out.println(b.getChunk(10));
    	}
    	
    }
    
    public void testScanner() {    	
    	String s = "123-133";    	
    	Scanner sc = new Scanner(s);
    	
    	if (!s.contains("-")) {
        	sc.useDelimiter(",");
        	while (sc.hasNextInt()) {
        		System.out.println(sc.nextInt());
        	}   		
    	}
    	else
    	{
    		sc.useDelimiter("-");   
    		int min=sc.nextInt();
    		int max=sc.nextInt();
    		for (int i=min;i<=max;i++)
    		{
    			System.out.println(i);
    		}
    	}

    }
    
    public void testSearchKeyword() {
    	P2PFileManager a = new P2PFileManager();
    	P2PFile b = a.SearchKeywords("log");
    	System.out.println(b.filename);
    }
   /*public void testSHAChecksum() throws Exception {
	   SHAChecksum n = new SHAChecksum();
	   n.getSHAChecksum();
   }*/


    public void testGenerateId() throws Exception {
    	UDPClient s = new UDPClient(); 
    	System.out.print(s.generateId());
    }

}
